layui.use(['form','layer','upload'], function () {
    var  form = layui.form
        , layer = layui.layer
        ,upload = layui.upload;

    $ = layui.$

    //普通图片上传
    var uploadInst = upload.render({
        elem: '#upImg'
        ,url: '/Anime/video/up' //改成您自己的上传接口
        ,before: function(obj){
            //预读本地文件示例，不支持ie8
            obj.preview(function(index, file, result){
                $('#displayImg').attr('src', result); //图片链接（base64）
            });
        }
        ,done: function(res){
            if(res.code == 0){
                $("#coverPath").val(res.msg)
                layer.msg("上传成功！")
            }else {
                layer.msg(res.msg)
            }
        }
        ,error: function(){
            //演示失败状态，并实现重传
            var demoText = $('#demoText');
            demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
            demoText.find('.demo-reload').on('click', function(){
                uploadInst.upload();
            });
        }
    });

    //视频上传
    upload.render({
        elem: '#upVideo'
        ,url: '/Anime/video/up' //改成您自己的上传接口
        ,accept: 'video' //视频
        ,done: function(res){
            if(res.code == 0){
                $("#videoPath").val(res.msg)
                layer.msg("上传成功！");
            }else {
                layer.msg(res.msg)
            }
        }
    });
});

function judge(res) {
    if(res.code == 0){
        layer.msg(res.msg)
    }else {
        layer.msg(res.msg)
    }
}